﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Genesis.ShapeImage;

namespace TestShapeImage
{
    public partial class frmTestMain : Form
    {
        public frmTestMain()
        {
            InitializeComponent();
        }

        private void frmTestMain_Load(object sender, EventArgs e)
        {
            cmbExtension.SelectedIndex = 0;
            setDefaultImageName();
            lblErrMessageValue.Text = string.Empty;
        }
        private void setDefaultImageName()
        {
            string pathToZipFile = txtPathToZipFile.Text;
            string imageName = Path.GetFileNameWithoutExtension(pathToZipFile);
            txtImageName.Text = imageName;
        }

        private void btnConvert_Click(object sender, EventArgs e)
        {
            try
            {
                string pathToZipFile = txtPathToZipFile.Text;
                string outputDirectory = txtOutputDirectory.Text;
                string imageName = txtImageName.Text;
                Transformer tran = new Transformer();
                if (txtPathToPointImage.Text != string.Empty)
                    tran.pathToPointImage = txtPathToPointImage.Text;
                string imageFormat = cmbExtension.Text;
                double[] drawingBounds = new double[4];
                string errMessage = string.Empty;
                lblErrMessageValue.Text = string.Empty;
                int returnCode= tran.convertShapeToImage(pathToZipFile, outputDirectory, imageName, imageFormat,
                    out drawingBounds, out errMessage);
                lblReturnCodevalue.Text = returnCode.ToString();
                if (returnCode != 0)
                    lblErrMessageValue.Text = errMessage;
                else
                    lblErrMessageValue.Text = "Done";
            }
            catch (Exception ex)
            {
                
                lblErrMessageValue.Text = ex.Message;
            }
        }
    }
}
